package com.example.administrator.maizuofilm.hot;

import android.util.Log;

import com.example.administrator.maizuofilm.bean.Hot;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

/**
 * Created by Administrator on 2016/7/14.
 */
public class HotPresenter implements HotContract.HotPresenter {
    private HotContract.HotModel hotModel;
    private HotContract.HotView hotView;

    public HotPresenter(HotContract.HotView hotView, HotContract.HotModel hotModel) {
        this.hotView = hotView;
        this.hotModel = hotModel;
        EventBus.getDefault().register(this);
    }

    @Override
    public void init() {
        hotModel.init();
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void sub(Hot hot) {
        if (hot == null) {
            hotView.onInitFail("失败");
        } else {
            hotView.onInitSuccess(hot);
        }
    }
}
